package com.lwc.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.lwc.client.StockRemoteClient;
import com.lwc.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StockController implements StockRemoteClient {


    @Autowired
    StockService stockService;

    @SentinelResource( value = "更新库存", fallback = "fallback")
    @Override
    public int reduceStock(int gid, int num) {

       int i= stockService.reduceStock(gid,num);
        return i;
    }

     public  int fallback(int gid, int num,Throwable e){
         System.out.println("异常"+e.toString());
    return 0;
    }

}
